﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DevComponents.DotNetBar;
using System.ComponentModel;
using QFlow.Core;

namespace QFlow.Utils
{
    public class SecurityRibbonPanel : RibbonPanel
    {

        public SecurityRibbonPanel()
        {

        }

        protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
        {
            if (this.Controls != null)
            {
                foreach (var item in this.Controls)
                {
                    SecurityRibbonBar bar = item as SecurityRibbonBar;
                    if (bar != null)
                    {
                        if (Authentication.CurrentUser != null)
                        {
                            if (Authentication.CurrentUser.HasPermission(bar.PermissionName))
                                bar.Visible = true;
                            else bar.Visible = false;
                        }
                    }
                }
            }
            base.OnPaint(e);
        }
    }
}
